﻿<!DOCTYPE html>
<html>
<head>
	<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
    <meta charset="utf-8">
    <meta content="微信小游戏" name="Keywords">
    <meta name="description" content="值得收藏的网站。">
    <meta name="viewport" content="initial-scale=1.0, maximum-scale=1.0, user-scalable=no">
    <title>【大逃杀】智商超过130的人才能玩到第40关哦</title>
	<link rel="stylesheet" type="text/css" href="/addons/sinrch_dataosha/template/mobile/style/css/style.css">
	<script src="/addons/sinrch_dataosha/template/mobile/style/js/jquery.min.js"></script>
	{php echo register_jssdk(false);} 
</head>
<body style="">
   	<div class="point">0</div>
    <div class="point">0</div>
   	<div class="tips">
		已有:<span style="color:#4169E1">{$subscribe_num}</span>人在玩<br><br>
		<b>本游戏由 {$subscribe_skill} 开发<br/>
		<span style="color:#4169E1">游戏玩法: 将手放在屏幕,使竿变长</span><br/>
		据说智商超过130的人才能玩到40关,您呢？<br />
		<b>关注公众号：<a href="{$subscribe_url}" target="_self" style=" font-size:14px; color:#4169E1">{$subscribe_skill}</a>
   	</div>
   <div id="main">
		<div class="wall"></div>
		<div class="wall new" style="left: 50%;"></div>
		<div class="stick" style="-webkit-transform-origin: 0px 0px; -webkit-transform: rotate(-90deg);"></div>
		<div class="stickMan">
		<img src="/addons/sinrch_dataosha/template/mobile/style/images/stick_stand.png" width="5%"></div>
   </div>
   <!--游戏结束弹层-->
	<div class="gameOver">
		<h2>游戏结束!</h2>
		<div class="showPoint">
			<p>分数</p>
			<p class="newPoint">0</p>
			<p>最佳</p>
			<p class="bestPoint">0</p>
		</div>
		<div class="btn again">再跳一次悬崖</div>
		<div class="btn again"><a href="{$subscribe_url}">关注我们</a></div>
	</div>
	<div id="mask">
		<img src="/addons/sinrch_dataosha/template/mobile/style/images/share_img10.gif">
	</div>
	<div class="reloadImg" style="display: none;">
		<img src="/addons/sinrch_dataosha/template/mobile/style/images/stick01.gif">
	</div>
	<script type="text/javascript">
		var longStick;
		var shortStick;
		var screenWidth = document.documentElement.clientWidth;
		var point = 0;
		var speed = "5%";
		function touchSatrtFunc(evt) {
			if(point>=2){
				$(".tips").hide();
			}
			evt.preventDefault();
			document.addEventListener('touchend', touchEndFunc, false);
			initStick();
			//longStick = setInterval(function(){
			//    $('.stick').css({width:'+='+speed});
			//},30);
			getLong();
			document.removeEventListener('touchstart', touchSatrtFunc, false);
		}
		function getLong() {
			if(point>5){
					//alert(point);
					speed="5%";	
				}
			longStick = setInterval(function() {
				
				var stickWidth = getWidthNumber($('.stick').css('width'));
				if(stickWidth<=screenWidth){
					$('.stick').css({width:'+='+speed});
				}else{
					clearInterval(longStick);
					getShort();
				}
			},30);
		}
		function getShort() {
			if(point>5){
				//alert(point);
				speed="10%";	
			}
			shortStick = setInterval(function() {
				var stickWidth = getWidthNumber($('.stick').css('width'));
				if(stickWidth>0){
					$('.stick').css({width:'-='+speed});
				}else{
					clearInterval(shortStick);
					getLong();
				}
			},30);
		}
		function getWidthNumber(ele){
			if (ele) {
				var WidthNumber = ele.substr(0,ele.length-2);
				WidthNumber = Number(WidthNumber);
				return WidthNumber;
			}
		}
		function touchEndFunc(evt) {
			clearBind();
			evt.preventDefault();
			clearInterval(longStick);
			clearInterval(shortStick);
			setTimeout(function(){
				$('.stick').css('transition','.6s');
				$('.stick').css('transform','rotate(0deg)');
				setTimeout('checkStickLong.check()',600);
			},200);
		}
		function touchMoveFunc(evt){
			evt.preventDefault();
		}
		function initStick() {
			$(".stick").css({'transition':'0','transform':'rotate(-90deg)','width':'0','left':'20%'});
		}		
		function init(){
			$(".stick").css({'transform-origin':'0 0','transform':'rotate(-90deg)'});
			addBind();
			document.addEventListener('touchmove', touchMoveFunc, false);
			$(".again").click(function(){
				$(".gameOver").css('display','none');
				addBind();
				$(".point,.tips").css('display','block');
				point = 0;
				speed="5%";
				$(".point").html(point);
				$(".wall").eq(0).css({'left':'0','width':'20%'});
				$(".new").css({'left':'50%','width':'20%'});
				$(".stick").css('transition','0')
				$(".stick").css('width','0');
				$(".stickMan").css({'left':'15.5%','bottom':'66.5%'});
				$("body").css('background-position-x', '0');
				$(".stickMan img").attr({'src':'/addons/sinrch_dataosha/template/mobile/img/stick_stand.png'});
				$(".shouji").css({"left":"0%"});
			});
			$(".share").click(function(){
				$("#mask").css('display','block');
			});
			$("#mask").click(function(){
				$("#mask").css('display','none');
			});
		}
		function addBind() {
			document.addEventListener('touchstart', touchSatrtFunc, false);  
		}
		function clearBind() {
			document.removeEventListener('touchstart', touchSatrtFunc, false);
			document.removeEventListener('touchend', touchEndFunc, false);
		}
		function orientationChange() {
		switch(window.orientation) {
		　　case 0: 
				addBind();
				$("body").css('transform','');
				break;
	
		　　case -90: 
				clearBind();
				alert("游戏要竖屏玩哟！！！");
				$("body").css('transform','rotate(90deg)');
	
				break;
	
		　　case 90:   
				clearBind();
				alert("游戏要竖屏玩哟！！！");
				$("body").css('transform','rotate(-90deg)');
				break;
	
		　　case 180:   
				addBind();
				$("body").css('transform','rotate(0deg)');
			　　break;
	
		}
	}
		$(document).ready(function(){
			init();
			orientationChange();
			window.onorientationchange = orientationChange;
			shareToWeixin();
		})
		var checkStickLong = {
		check:function(){
		var stickLong = this.getWidthNumber($(".stick").css('width'));
		var maxLong = this.getWidthNumber($(".wall").eq(1).css('left'))+this.getWidthNumber($(".wall").eq(1).css('width'))-screenWidth*0.2;
		var minLong = this.getWidthNumber($(".wall").eq(1).css('left'))-screenWidth*0.2;
		//alert(minLong);
		if (stickLong<maxLong&&stickLong>minLong) {
			var me=this;
			me.run();
			setTimeout(function(){
		        me.getPoint();
		        me.getNewWall();
			},1100);
		} else if(stickLong>maxLong){
			clearBind();
			this.getDown();
		} else {
			clearBind();
			this.getDown();
		}
	},
	run:function(){
		$(".stickMan img").attr({'src':'/addons/sinrch_dataosha/template/mobile/img/stick.gif'});
		var moveNumber = this.getWidthNumber($(".wall").eq(1).css('left'))+this.getWidthNumber($(".wall").eq(1).css('width'))-screenWidth*0.2;
		$(".stickMan").animate({left:'+='+moveNumber+'px'},1000);
		$("body").css('background-position-x', '-'+(point+1)*20+'px');
		setTimeout(function(){
			$(".stickMan img").attr({'src':'/addons/sinrch_dataosha/template/mobile/img/stick_stand.png'});
		},1000);
	},
	getDown:function(){
		$(".stickMan img").attr({'src':'/addons/sinrch_dataosha/template/mobile/img/stick.gif'});
		var me = this;
		$(".stickMan").animate({left:'+='+$(".stick").css('width')},1000);
		$("body").css('background-position-x', '-'+(point+1)*30+'px');
		setTimeout(function(){
			$('.stick').css('transform','rotate(90deg)');
		    $(".stickMan").animate({bottom:'-'+$(".stickMan").css('height')},300);
		},1000);
		setTimeout(function(){
			me.showResult();
		},1300);
	},
	getPoint:function(){
		point++;
		$(".point").html(point);
		var len=$(".shouji").css("left");
		var len1=$("#main").width();
		var kk=parseInt(len)-parseInt(len1)/6;
		
		$(".shouji").animate({"left":kk+"px"},1000);
		//parseInt(len)-4
		//$(")
	},
	getNewWall:function(){
		this.setNewWall();
		//$('.stick').css('transition','0');
		//$(".wall").animate({left:'-='+$(".new").eq(0).css('left')},500);
		//$(".stick").animate({left:'-='+$(".new").eq(0).css('left')},500);
		//$(".stick").css('transform','translateX(-'+$(".new").eq(0).css('left')+')');
		setTimeout(this.resetWall,550);
		
	},
	resetWall:function(){
		addBind();
		$('.wall').eq(0).remove();
		$('.new').eq(0).removeClass('new');
		$('.init').eq(0).removeClass('init');
	},
	getWidthNumber:function(ele){
   		if (ele) {
   			var WidthNumber = ele.substr(0,ele.length-2);
   			WidthNumber = Number(WidthNumber);
   			return WidthNumber;
   		}
    },
    setNewWall:function(){
    	//新墙设置
    	var newWallSpacing =Math.random()*55+5+20;
   		var newWallWidth = Math.random()*Math.min(90-newWallSpacing,15)+5;
        var tpl = '<div class="wall new init" style="width:'+newWallWidth+'%;left:100%"></div>';
		$("#main").append(tpl);
		
		//移动设置
		var moveNumber = this.getWidthNumber($(".wall").eq(1).css('left'))+this.getWidthNumber($(".wall").eq(1).css('width'))-screenWidth*0.2;
		$(".wall").eq(0).animate({left:'-='+moveNumber+'px'},500);
		$(".wall").eq(1).animate({left:'-='+moveNumber+'px'},500);
		$(".wall").eq(2).animate({left:newWallSpacing+'%'},500);
		$('.stick').css('transition','0');
		$(".stick").animate({left:'-='+moveNumber+'px'},500);
		$(".stickMan").animate({left:'-='+moveNumber+'px'},500);
		
		
    },
    showResult: function() {
    	$(".point,.tips").css('display','none');
    	$(".newPoint").html(point);
    	$(".gameOver").css('display','block');
    	this.setBestPoint();
    }, 
    setBestPoint: function() {
    	var bestPoint = window.sessionStorage.getItem('stickManPoint');
        if(!bestPoint){
        	bestPoint = point;
        	window.sessionStorage.setItem('stickManPoint',point);
        } else if(bestPoint<point){
        	bestPoint = point;
        	window.sessionStorage.setItem('stickManPoint',point);
        }
        $(".bestPoint").html(bestPoint);
        shareToWeixin();
    }
};
	function shareToWeixin(){
	wx.ready(function () {
		var desc = '智商超过130的人才能玩到第40关！！！';
		var bestPoint = window.sessionStorage.getItem('stickManPoint');
		if(!bestPoint||bestPoint==0){
			desc ='智商超过130的人才能玩到第40关！！';
		} else {
			if(bestPoint>=40){
				desc ='大逃杀，我居然获得了'+bestPoint+'分！天才啊！';
			}else if(bestPoint<40){
				desc ='大逃杀，我才得了'+bestPoint+'分！还需要继续努力哦！';
			}
		}
		var sharedata = {
			title: desc,
			desc: desc,
			link: window.location.href,
			imgUrl: '{$_W['attachurl']}{$photo}',
			success: function(){
				alert('分享成功');
			},
			cancel: function(){
				alert('分享取消');
			}
		};		
		wx.onMenuShareAppMessage(sharedata);
		wx.onMenuShareTimeline(sharedata);
		wx.onMenuShareQQ(sharedata);
	});
	} 
	</script>
</body>
</html>
